package com.woorigil.social.domain.searcher;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Component;

@Component
public class IndexCreator {
//	String text = "경기 이천 여름나기 워터파크 할인";

	public List<String> create(String text) {
		List<String> indexes = new ArrayList<String>();
//		int totalIndexLowCount = 0;
		int totalLatterCount = 0;
		text = text.replaceAll(" ", "");
		text = text.replaceAll("&", "");
		text = text.replaceAll("\\[", "");
		text = text.replaceAll("]", "");
		text = text.replaceAll("\\\\", "");
		text = text.replaceAll("\\/", "");
		text = text.replaceAll("\\+", "");
		text = text.replaceAll("\\(", "");
		text = text.replaceAll("\\)", "");
		text = text.replaceAll("\\,", "");
		text = text.replaceAll("\\.", "");
		text = text.replaceAll("\\-", "");
		text = text.replaceAll("\\!", "");
		text = text.replaceAll("\\`", "");
		text = text.replaceAll("\\%", "");
		for (int i=0; i<text.length(); i++) {
			String subText = text.substring(i, text.length());
			for (int j=0; j<subText.length(); j++) {
				String index = subText.substring(0, j+1);
				indexes.add(index);
//				System.out.println(index);
//				totalIndexLowCount++;
				totalLatterCount = totalLatterCount + index.length();
			}
		}
//		System.out.println("textLength : " + text.length());
//		System.out.println("totalIndexLowCount : " + totalIndexLowCount);
//		System.out.println("totalLatterCount : " + totalLatterCount);
		return indexes;
	}
}
